package ah.fm;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;

public class FreeMarkerTest {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		Configuration cfg = new Configuration();
		cfg.setDirectoryForTemplateLoading(new File("src/templates"));
		cfg.setDefaultEncoding("UTF-8");
		
		Template t = cfg.getTemplate("test.txt");//模板文件
		Map root = new HashMap();
		root.put("message", "世界,你好");//数据
		
		FileOutputStream fos = new FileOutputStream("src/templates/test2.txt");
		OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
		BufferedWriter bw = new BufferedWriter(osw);
		t.process(root, bw);
		
	}

	public static void main() {
		//${(test.articleContent!"")substring（0,10）}
	}

}
